#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

const int N = 1e5 + 10;

int gcd(int x, int tmp)
{
    //x < tmp
    int i = 2;
    for (; i <= x; i++)
    {
        if (x % i == 0 && tmp % i == 0)
        {
            return i * gcd(x / i, tmp / i);
        }
    }

    return 1;
}

//int main() {
//    long long n, x;
//    long long arr[N];
//    long long tmp = 0;
//    cin >> n >> x;
//
//    for (int i = 0; i < n; i++)
//    {
//        cin >> tmp;
//        if (x >= tmp) x += tmp;
//        else x += gcd(x, tmp);
//    }
//
//    cout << x << endl;
//
//    return 0;
//}

 int maxValue(vector<vector<int> >& grid) {
        int n = grid.size(), m = grid[0].size();
        vector<vector<int>> vv(n + 1);
        vv[0].resize(m + 1);
        for (int i = 0; i < n; i++)
        {
            vv[i + 1].resize(m + 1);
            for (int j = 0; j < m; j++)
            {
                if(vv[i][j + 1]  > vv[i + 1][j])
                {
                    vv[i + 1][j + 1] = grid[i][j] + vv[i][j + 1];
                }
                else
                {
                    vv[i + 1][j + 1] = grid[i][j] + vv[i + 1][j];
                }
            }
        }

        return vv[n][m];
}

 void test()
 {
     int t = 1, n = 6; 
     vector<string> vs;
     //cin >> t;
     while (t--)
     {
         //cin >> n;
         vs.resize(n);
         
         vs[0] = "aaca";
         vs[1] = "bbbb";
         vs[2] = "ccccccc";
         vs[3] = "bbbsssd";
         vs[4] = "ddddbsssd";
         vs[5] = "sssdaa";
         for (int i = 0; i < n; i++)
         {
             //cin >> vs[i];
             sort(vs[i].begin(), vs[i].end());
         }
         int ret = 0;
         string mins, maxs;
         int left = 0, right = n - 1;
         while (left <= right)
         {
             mins = vs[left++];
             maxs = vs[right--];
             ret = 0;
             if (mins.size() > maxs.size())
             {
                 swap(mins, maxs);
             }

             for (int i = 0; i < mins.size(); i++)
             {
                 if (mins[i] == maxs[i])
                 {
                     ret = 1;
                     break;
                 }
                 else if (mins[i] > maxs[i])
                 {
                     int j = i + 1;
                     for (; j < maxs.size(); j++)
                     {
                         if (maxs[j] == mins[i])
                         {
                             ret = 1;
                             break;
                         }
                     }
                     if (ret == 1 || maxs[j - 1] < mins[i]) break;  
                 }
                 else
                 {
                     
                     for (int j = 0; j < i; j++)
                     {
                         if (maxs[j] == mins[i])
                         {
                             ret = 1;
                             break;
                         }
                     }
                     if (ret == 1) break;
                 }

             }

             if (ret == 0) break;
         }
         if (ret) cout << "Yes" << endl;
         else cout << "No" << endl;

     }
 }


int main()
{
    /*vector<vector<int> > grid = { {1,3,1},{1,5,1},{4,2,1} };
    cout << maxValue(grid);*/
    test();
    return 0;
}